package top.swle.austers.controller;

import com.google.gson.Gson;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.web.bind.annotation.*;
import top.swle.austers.bean.People;
import top.swle.austers.bean.ResponseBean;
import top.swle.austers.bean.User;
import top.swle.austers.mapper.ContactWayMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@RestController
@RequestMapping("/contact_way")
public class ContactWayController {

    @Autowired
    ContactWayMapper contactWayMapper;
    @PostMapping("/query")
    public ResponseBean getContactWay(@RequestBody People people){
        try {
            List<People> users = contactWayMapper.queryContactWay(people.getName());
            Gson gson = new Gson();
            String json = gson.toJson(users);
            System.out.println(json);
            return new ResponseBean(1,"successful",users);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseBean(-1,"查询失败",null);
        }
    }
}
